//
//  KRXKTipsAlertView.m
//  KEREN
//
//  Created by MW on 2023/5/5.
//

#import "KRXKTipsAlertView.h"

@implementation KRXKTipsAlertView

-(instancetype)initWithFrame:(CGRect)frame tips:(NSString *)tips{
    self = [super initWithFrame:frame];
    if(self){
        self.backgroundColor = [UIColor clearColor];
        self.layer.borderColor = Whire_Color.CGColor;
        self.layer.borderWidth = 0.5;
        self.layer.cornerRadius = self.bounds.size.height / 2;
        self.clipsToBounds = YES;
        BubbleLayer *bbLayer = [[BubbleLayer alloc]initWithSize:self.bounds.size];
        // 矩形框的圆角半径
        bbLayer.cornerRadius = self.bounds.size.height / 2;
        // 凸起那部分暂且称之为“箭头”，下面的参数设置它的形状
        bbLayer.arrowHeight = 6;   // 箭头的高度（长度）
        bbLayer.arrowWidth = 8;    // 箭头的宽度
        bbLayer.arrowDirection = ArrowDirectionRight;
        bbLayer.arrowPosition = 0.5;// 箭头的相对位置
        bbLayer.arrowRadius = 0;    // 箭头处的圆角半径
       //[self.layer setMask:[bbLayer layer]];

        [self addUIwithTips:tips];
    }
    return self;
}

- (void)addUIwithTips:(NSString *)tips{
    UILabel *label = [UILabel setLblText:tips font:BFont(12) withColor:Whire_Color inSubView:self];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.right.offset(-10);
        make.centerY.equalTo(self);
    }];
}
@end
